package net.hxz.modules.controller.frontEnd;

import net.hxz.modules.controller.BaseController;
import net.hxz.modules.services.ITypeService;
import net.wy.myBatisPlugin.page.model.PageRowBounds;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 网站统一入口
 * @author OYJ
 */
@Controller
@RequestMapping(value="/type/")
public class TypeController extends BaseController {
	
	@Autowired
	private ITypeService typeService;
	
	@RequestMapping("index-{lang}")
	public String index(@PathVariable String lang, Long typeId, ModelMap map) {
		map.put("t", typeService.get(typeId));
		map.put("list", typeService.getWithChildren(typeId));

		map.put("lang", lang.equals("en") ? 0 : 1);
		map.put("jsp", "type/index");
		return PHONE_MAIN_PATH;
	}
	
	@RequestMapping("next-{lang}")
	public String next(@PathVariable String lang, Long typeId, ModelMap map) {
		map.put("t", typeService.get(typeId));
		map.put("list", typeService.getWithChildren(typeId));

		map.put("lang", lang.equals("en") ? 0 : 1);
		map.put("jsp", "type/next");
		return PHONE_MAIN_PATH;
	}
	
	@RequestMapping("last-{lang}")
	public String last(@PathVariable String lang, Long typeId, ModelMap map) {
		map.put("t", typeService.get(typeId));
		map.put("list", typeService.getWithChildren(typeId));

		map.put("lang", lang.equals("en") ? 0 : 1);
		map.put("jsp", "type/last");
		return PHONE_MAIN_PATH;
	}
}
